library(plotly); library(datasets); library(dplyr)
data <- data.frame(state.x77) %>%
mutate(region = state.region,
abb = state.abb,
name = state.name,
division = state.division)
plot_ly(data, x = ~HS.Grad,
y = ~Life.Exp,
type = "scatter",mode = "markers",
size = ~Population, color = ~region,
text = ~name) %>%
layout(title = "High School Graduation Rate vs. Life Expectancy")